<!DOCTYPE html>
<html>	
<head>
<title>Login</title>
<meta name="viewport" content="width=device-width, initial-scale=1">

	<style>

		/* reset */
		.clear{clear:both;}/* clear float */

		body{
			background: url("../img/bg1.jpg");
			font-family: 'Open Sans', sans-serif;
			background-size:cover;
			-webkit-background-size:cover;
			-moz-background-size:cover;
			-o-background-size:cover;

		}
		/*--/close--*/
		h1 {
			font-family: 'Exo 2', sans-serif;
			text-align: center;
			padding-top: 4em;
			font-weight: 400;
			color: #2B2B36;
			font-size: 2em;
		}
		.login-form {
			background: #2b2b36;
			position: relative;
			width: 400px;

			margin: 3% auto 0 auto;
			text-align: center;
			border-radius: 15px;
			-webkit-border-radius: 15px;
			-moz-border-radius: 15px;
			-o-border-radius: 15px;
		}
		label.lbl-1 {
			background: #6756ea;
			width: 20px;
			height: 20px;
			display: block;
			float: right;
			border-radius: 50%;
			margin: 16px 10px 0px 0px;
		}
		label.lbl-2 {
			background: #ea569a;
			width: 20px;
			height: 20px;
			display: block;
			float: right;
			border-radius: 50%;
			margin: 16px 10px 0px 0px;
		}
		label.lbl-3 {
			background: #f1c85f;
			width: 20px;
			height: 20px;
			display: block;
			float: right;
			border-radius: 50%;
			margin: 16px 10px 0px 0px;
		}


			label.lbl-1 {
				margin: 8px 10px 0px 0px;
			}
			label.lbl-2 {
				margin: 8px 10px 0px 0px;
			}
			label.lbl-3 {
				margin: 8px 10px 0px 0px;
			}


</style>


</head>
<body>

 <h1>请扫码登录</h1>
<div class="login-form">
	<div class="close"> </div>
		<div class="head-info">
			<label class="lbl-1"> </label>
			<label class="lbl-2"> </label>
			<label class="lbl-3"> </label>
		</div>
			<div class="clear"> </div>
		<div style="width: 200px;height: 250px;margin: 0 auto;margin-top: 50px;">
				<div id="makeCode">

				</div>
		</div>
</div>
 <script src="/js/qrcode.min.js"></script>
 <script src="/js/axios.min.js"></script>
<script>

    var key ={type:3,

        sessionId:''
    }
    var timer;
    var qrcode = new QRCode(document.getElementById("makeCode"), {
        width: 200,
        height: 200
    });
    function getSessid() {
        axios.post('/common/getSessionId', {})
            .then(function (response) {
                var res = response.data;
                if (res.code == 200) {
                    // key += ("=" + res.data.sessionId);
                    key.sessionId=res.data.sessionId
                    makeCode();
                }
                else {
                    alert(res.data.message);
                }
            })
            .catch(function (error) {
                console.log(error);
            });
    }
    function makeCode() {
        console.log(key + "--");
        qrcode.makeCode(JSON.stringify(key))
    }
    //是否使用微信登录
    function loopIslogin() {
        axios.post('/common/isLogin', {})
            .then(function (response) {
                var res = response.data;
                switch (res.code) {
                    case 200:window.clearInterval(timer);
                        // alert("扫码成功");
                        window.location.href="/html/index"
                        break;
                    case 202:window.clearInterval(timer);
                        alert(res.message);break;
                    default:console.log(res.message)
                }
            })
            .catch(function (error) {
                console.log(error);
            });
    }
    getSessid();
    timer= window.setInterval(loopIslogin,1000);

</script>


</body>
</html>